import { getunRead } from '../services/letterCheck';

export default {
  namespace: 'letterCheck',
  state: {
    data: [],
  },
  effects: {
    *getunRead ({ payload, callback }, { call, put }) {
      yield put({
        type: 'save',
        payload: { loading: true },
      })
      const response = yield call(getunRead, payload)
      yield put({
        type: 'save',
        payload: {
          loading: false,
          data: response.data,
        },
      })
      if (callback) callback(response)
    },
  },
  reducers: {
    save(state, action) {
      return {
        ...state,
        ...action.payload,
      };
    },
  },
};
